﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;
/// <summary>
///News 的摘要说明
/// </summary>
public class Daily
{  
  
  

    //发表日志（level为 0：新闻；1:英雄帖；2：普通日志；3：站内信） （replynum初始都设为0）（sendto只有在 level为3是有效）(lastday：英雄帖的有效天数）
    public void AddDaily(String content, String title, int uid, int level, int replynum, String sendto, int lastday)
    {
        byte[] bcontent = Encoding.Default.GetBytes(content);
        byte[] btitle = Encoding.Default.GetBytes(title);
        byte[] bsendto = Encoding.Default.GetBytes(sendto);
        String SmdStr = String.Format("insert into _Daily(_Content,_Title,_Uid,_Level,_ReplyNum,_UpdateTime,_AddTime,_SendTo,_Time)values(@bcontent,@btitle,@uid,@level,@replynum,getdate(),getdate(),@bsendto,dateadd(minute,@lastday,getdate()))");
        SqlCommand Smd;
        SqlHelper Shp = new SqlHelper();
        SqlParameter[] MyParam=new SqlParameter[7];
        MyParam[0] =new SqlParameter("@bcontent", bcontent);
           MyParam[1] =new SqlParameter("@btitle", btitle);
            MyParam[2] =new SqlParameter("@uid", uid);
           MyParam[3] =new SqlParameter("@level", level);
           MyParam[4] =new SqlParameter("@replynum", replynum);
            MyParam[5] =new SqlParameter("@bsendto", bsendto);
            MyParam[6] = new SqlParameter("@lastday", lastday);
            Smd = Shp.GetCommand(SmdStr, MyParam);
        Smd.ExecuteNonQuery();        
    }
    public  SqlDataReader ShowDaily(int uid)
    {
        String SmdStr = "select * from _Daily";
        SqlHelper Shp=new SqlHelper();
        SqlCommand Smd = Shp.GetCommand(SmdStr, null);
      return Smd.ExecuteReader();
  

    }
}
